package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.NursingProjectPlanDto;
import com.zzyl.entity.NursingProjectPlan01;
import com.zzyl.mapper.NursingProjectPlanMapper;
import com.zzyl.service.NursingProjectPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class NursingProjectPlanServiceImpl implements NursingProjectPlanService {

    @Autowired
    private NursingProjectPlanMapper nursingProjectPlanMapper;

    @Autowired
    public NursingProjectPlanServiceImpl(NursingProjectPlanMapper nursingProjectPlanMapper) {
        this.nursingProjectPlanMapper = nursingProjectPlanMapper;
    }

    /**
     * 批量增加护理项目计划
     *
     * @param nursingProjectPlan
     */
    @Override
    public int add(NursingProjectPlanDto nursingProjectPlan) {
        NursingProjectPlan01 projectPlan = BeanUtil.toBean(nursingProjectPlan, NursingProjectPlan01.class);
        return nursingProjectPlanMapper.insert(projectPlan);
    }

    /**
     * 批量增加护理项目计划
     *
     * @param projectPlans
     */
    @Override
    public void addList(List<NursingProjectPlan01> projectPlans) {

        for (NursingProjectPlan01 projectPlan : projectPlans) {

            nursingProjectPlanMapper.insert(projectPlan);

        }

    }

    @Override
    public int deleteByIds(List<Long> ids) {
        return nursingProjectPlanMapper.deleteByIds(ids);
    }

    /**
     * 根据护理计划id删除
     *
     * @param id
     */
    @Override
    public void deleteByNursingPlanId(Long id) {
        nursingProjectPlanMapper.deleteByNursingPlanId(id);
    }

}
